﻿namespace SmartPlant.Model
{
    public class RESTfulResult
    {
        /// <summary>
        /// 状态码。oh是500，bar是400。
        /// </summary>
        public int? statusCode { get; set; }

        /// <summary>
        /// 执行成功
        /// </summary>
        public bool succeeded { get; set; } = false;

        /// <summary>
        /// 错误信息
        /// </summary>
        public string errors { get; set; } = null;

        /// <summary>
        /// 附加数据
        /// </summary>
        public object extras { get; set; } = null;

        /// <summary>
        /// 时间戳
        /// </summary>
        public long timestamp { get; set; }

        /// <summary>
        /// 正常的提示信息
        /// </summary>
        public string msg { get; set; } = string.Empty;
    }

    /// <summary>
    ///  RESTful 风格结果集
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class RESTfulResult<T> : RESTfulResult
    {
        /// <summary>
        /// 数据。但是后端通过Oops.oh、Oops.bah返回时，data会是null，信息会在errors里。
        /// </summary>
        public T data { get; set; } = default;
    }

    /// <summary>
    /// RESTful 风格分页结果集
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class RESTfulResultPage<T> : RESTfulResult<PageResult<T>>
    {

    }

    /// <summary>
    /// 
    /// </summary>
    public class PageResult<T>
    {
        public int Count { get; set; }
        public T Data { get; set; } = default;
    }

    /// <summary>
    /// 给wpf端用的，把<see cref="FileContentResult"/>或者<see cref="MemoryStream"/>转为string
    /// </summary>
    public class FileContentResultBaseString
    {
        /// <summary>
        /// 文件名。如xxx.zip
        /// </summary>
        public string fileName { get; set; }
        /// <summary>
        /// 比如application/octet-stream 或者 application/zip
        /// </summary>
        public string ContentType { get; set; }
        /// <summary>
        /// 文件内容。
        /// </summary>
        public string Data { get; set; }
    }
}
